package org.metasketch.editor.timeline;

import org.metasketch.editor.Project;
import org.metasketch.model.IdDatabase;
import org.metasketch.model.ModelChangeManager;
import org.metasketch.reflection.RefUtil;

import com.rits.cloning.Cloner;

public class SnapshotHandler {

	// static Cloner cloner = new Cloner();

	public static Snapshot getSnapshot(Project project) {

		// try {
		// DeepCopyUtil deepCopyUtil = new DeepCopyUtil();
		//
		// Project clone = deepCopyUtil.deepCopy(project);
		//
		// return new Snapshot(clone);

		Cloner cloner = getCloner();

		Project clone = cloner.deepClone(project);
		return new Snapshot(clone);

		// } catch (DeepCopyException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }
		// return null;

	}

	private static Cloner getCloner() {
		Cloner cloner = new Cloner();

		cloner.dontClone(ModelChangeManager.class, IdDatabase.class,
				RefUtil.class);
		return cloner;
	}

	public static Project getProject(Snapshot snapshot) {

		Cloner cloner = getCloner();

		Project clone = cloner.deepClone(snapshot.getProject());
		
		return clone;
	}
}
